package com.tgpms.web.hongbo.task;

import com.tgpms.web.hongbo.service.ITubeDocumentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created By Riven on 2020-10-26
 */
@Component
public class TubeDocumentTask {

    private final Logger log = LoggerFactory.getLogger(TubeDocumentTask.class);

    @Resource
    private ITubeDocumentService tubeDocumentService;

    @Scheduled(cron = "0 0 22 * * *")
    public void syncTubeDocument() {
        log.info("定时同步任务开始");
        try {
            int i = tubeDocumentService.syncTubeDocument();
            if (i == -1) {
                log.info("定时同步任务失败：清空表失败");
            }
            log.info("定时同步任务结束");
        } catch (Exception e) {
            e.printStackTrace();
            log.info("定时同步任务失败：无法连接服务器");
        }
    }
}
